' Test 8 Infinite Pong the Movie (from SB b+ 2018-09-19) update 2021-02-18
' OK loc works fine for locate row; col
' Now try At col; row
' 2021-02-26 Big problem locating at illegal places?? this is broken by changes.
' odd because most recent changes involved strings but am splitting different?


' constants - test new var assignment 2021-02-25
' test extreme spacing conditions for new var assign with extra spaces

' you can put all the spacing you want between end of var and start of "
' but you can't put any space left of variable ??? 

' good as of 2021-02-27 variable assignments have some tolerance of space typos
Paddle1Y "      3
 Paddle2Y  "40
  PaddleWidth   "10
   BoundaryX1 =      Int( .5 * PaddleWidth ) + 1
    BoundaryX2 =     128 - int( .5 * PaddleWidth ) - 1
. 3 Paddle variables and 2 BoundriesX: ;Paddle1Y;/ ;Paddle2Y;/ ;PaddleWidth;/ ;BoundaryX1;/ ;BoundaryX2
  
' ball test new var assignment 2021-02-25
ballX "64
ballY "18
ballDX "2
ballDY "1
' . Ball variables: ;ballX;/ ;ballY;/ ;ballDX;/ ;ballDY
' just show print before continuing
' ? OK  ...press Enter;OK

' main
[
	Cls 
	GS DrawBoundary:
	GS Paddle1:
	GS Paddle2:
	GS Ball:
	Show -1
	Wait .05
]

DrawBoundary:
	row = Paddle1Y + 1
	col = BoundaryX1
	[
		At BoundaryX1, row
		. |
		At BoundaryX2, row
		. |
		row = row + 1
		Jmp row >= Paddle2Y
	]
Rtn

Paddle1:
	paddle1X = ballX - .5 * PaddleWidth
	At paddle1X, Paddle1Y
	. [XXXXXXXX]
Rtn

Paddle2:
	paddle2X = ballX - .5 * PaddleWidth
	At paddle2X, Paddle2Y
	. [XXXXXXXX]
Rtn

Ball:
	' update ball
	ballX = ballX + ballDX
	ballY = ballY + ballDY
	
	' keep ball in bounds
	If   ballX < BoundaryX1 + 1
		 ballX = BoundaryX1 + 1
		ballDX = ballDX * -1 
	Fi
	If   ballX > BoundaryX2 - 1
		 ballX = BoundaryX2 - 1
		ballDX = ballDX * -1 
	Fi
	If 	 ballY < Paddle1Y + 1
		 ballY = Paddle1Y + 1 
		ballDY = ballDY * -1 
		ballDX = ballDX + int( rnd * 3) - 1
	Fi
	If   ballY > Paddle2Y - 1
		 ballY = Paddle2Y - 1
		ballDY = ballDY * -1 
		ballDX = ballDX + int( rnd * 3) - 1
	Fi
	At ballX, ballY
	. O
Rtn